<%@ page pageEncoding="UTF-8" %>
<!doctype html>
<html lang="zh-cmn">
<head>
    <title>Document</title>
    <%@include file="/WEB-INF/jsp/header.jsp"%>
    <style>
        #tou span{
            font-weight: bold;
        }
        #Table{
            width: 100%;
            margin-top: 20px;
        }
        #Table tr{
            border: 1px solid #dddddd;
            height: 40px;
        }
        #Table tr td{
            padding-left: 15px;
        }
        .xinxi{
            font-size: 12px;
            padding-left: 5px;
        }
        #biao{
            height: 55px;
        }
        #biao td{
            font-size: 18px;
            font-weight: bold;
            color: #FFFFFF;
        }
        .qian{
            color: red;
            font-weight: bold;
            font-size: 17px;
        }
        .li{
            font-weight: bold
        }
        #ti td{
            color: #ffffff;
            font-weight: bold;
        }
        .x{
            height: 40px;
        }
    </style>
</head>
<body>
<div class="container-fluid">
    <div class="text-center">
        <span class="h3">销毁详情信息</span>
    </div>
    <div style="margin-top: 15px;">

        <form id="Dform" action="" style="width: 80%;margin: auto;">
            <div id="tou">
                <div style="margin-bottom: 5px;"><span>销毁单号:</span>${list[0].desNum}</div>
                <fmt:formatDate value="${list[0].destorymaster.desDate}" var="d" pattern="yyyy-MM-dd"></fmt:formatDate>
                <div><span>销毁日期:</span>${d}</div>
            </div>
            <table style="border: 1px solid #dddddd" id="Table">
                <tr class="text-center">
                    <td colspan="7" style="font-size:20px;font-weight: bold">基本信息</td>
                </tr>
                <tr><td colspan="6">
                    <span class="li">提交人:</span><span class="xinxi">${list[0].destorymaster.worker.woName}</span>
                </td>
                </tr>
                <tr><td colspan="6">
                    <span class="li">销毁方式:</span><span class="xinxi">${list[0].destorymaster.desMode}</span>
                </td>
                    <td rowspan="4" style="vertical-align: top">
                        <span class="li">审核意见:</span><br/>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${list[0].destorymaster.desViews}
                    </td>
                </tr>
                <tr><td colspan="6">
                    <span class="li">销毁单位:</span><span class="xinxi">${list[0].destorymaster.desUnit}</span>
                </td></tr>
                <tr><td colspan="6">
                    <span class="li">销毁状态:</span><span class="xinxi">${list[0].destorymaster.desState==0?"待销毁":"已销毁"}</span>
                </td></tr>
                <tr><td colspan="6">
                    <span class="li">审核结果:</span><span class="xinxi">${list[0].destorymaster.desAuditstate==0?"未审核":list[0].destorymaster.desAuditstate==1?"已通过":"未通过"}</span>
                    <input type="hidden" value="${list[0].destorymaster.desAuditstate}" id="desAuditstate" />
                </td></tr>
            </table>
            <table border="1" style="width: 100%;margin-top: 15px;">
                <tr id="biao" class="text-center" style="background: #BDC3C7;">
                    <td colspan="4">药品信息</td>
                    <td colspan="2">金额(元)</td>
                </tr>
                <tr id="ti" style="background: #BDC3C7;height: 40px;">
                    <td>药品名称</td>
                    <td>药品单位</td>
                    <td>库存数量</td>
                    <td>公司名称</td>
                    <td>进价</td>
                    <td>金额小计</td>
                </tr>

                <c:forEach items="${list}" var="det">
                    <tr class="x">
                        <td>${det.druginfo.drugName}
                            <input type="hidden" name="stoNum" value="${det.stoNum}" />
                        </td>
                        <td>${det.druginfo.drugUnit}</td>
                        <td>${det.detNumber}</td>
                        <td>${det.provider.proName}</td>
                        <td class="qian">￥${det.detPrimecost}</td>
                        <td class="qian">￥${det.detNumber*det.detPrimecost}</td>
                    </tr>
                </c:forEach>
            </table>
            <div class="text-center" style="margin-top: 10px;">
                <c:if test="${list[0].destorymaster.desState!=1}">
                    <button class="btn btn-info" type="button" onclick="Destory()">
                        <i class="glyphicon glyphicon-floppy-remove"></i>
                        销毁</button>
                </c:if>
                <button class="btn btn-info" type="button" onclick="end()">
                    <i class="glyphicon glyphicon-menu-left"></i>
                    返回</button>
            </div>
            <input type="hidden" name="desNum" value="${list[0].desNum}" />
        </form>
    </div>
</div>

<%@include file="/WEB-INF/jsp/footer.jsp"%>
<script>
    function Destory() {
        var desAuditstate = $("#desAuditstate").val();
        if(desAuditstate==0){
            swal({
                title:"销毁提示",
                text:"该药品还未被审核!",
                type:"error",
                confirmButtonText:"确定",
            })
            return;
        }
        if(desAuditstate==2){
            swal({
                title:"销毁提示",
                text:"该审核还未通过!",
                type:"warning",
                confirmButtonText:"确定",
            })
            return;
        }
        var param = $("#Dform").serialize();
        console.log(param)
        $.post(ctx+"/stock/destoryDrugstock",param,function (msg) {
            if(msg=="true"){
                swal({
                    title:"销毁提示",
                    text:"销毁成功!",
                    type:"info",
                    confirmButtonText:"确定",
                }).then(function () {
                    location.href=ctx+"/stock/destoryView/index";
                })
            }else{
                toastr.warning("销毁失败!");
            }
        })
    }
    function end() {
        location.href=ctx+"/stock/destoryView/index";
    }
</script>
</body>
</html>
